<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Naive;
use LowCode\Node;
use LowCode\Support\JsExp;
use LowCode\Traits\Props\HasSize;

/**
 * 头像组组件 NAvatarGroup
 * @url https://www.naiveui.com/zh-CN/light/components/avatar#AvatarGroup-Props
 * @method static static make(array|JsExp $options,mixed $children = null) AvatarGroup组件
 */
class AvatarGroup extends Naive
{
    use HasSize;

    public function __construct(array|JsExp $options,mixed $children = null)
    {
        parent::__construct();
        if ($options){
            $this->options($options);
        }
        $this->children($children);
    }

    /**
     * 设置组件大小尺寸
     * @param string|int|JsExp $size 'small' | 'medium' | 'large'
     * @return $this
     */
    public function size(string|int|JsExp $size = 'small' | 'medium' | 'large'): static
    {
        return $this->prop('size',$size);
    }


    /**
     * 组内头像显示的最大个数
     * @param int|JsExp $max
     * @return $this
     */
    public function max(int|JsExp $max): static
    {
        return $this->prop('max', $max);
    }

    /**
     * 溢出标识的样式
     * @param string|array|JsExp $maxStyle
     * @return $this
     */
    public function maxStyle(string|array|JsExp $maxStyle): static
    {
        return $this->prop('max-style', $maxStyle);
    }

    /**
     * 头像组的选项
     * @param array|JsExp $options [['name'=>'','src'=>'']]
     * @return $this
     */
    public function options(array|JsExp $options): static
    {
        return $this->prop('options', $options);
    }

    /**
     * 组内头像是否垂直排列
     * @param bool|JsExp $bool
     * @return $this
     */
    public function vertical(bool|JsExp $bool = true): static
    {
        return $this->prop('vertical', $bool);
    }

    /**
     * 头像组头像 slot avatar
     * 参数 (info: { option: { src: string } })
     * @param Node $node
     * @return $this
     */
    public function slotAvatar(Node $node): static
    {
        return $this->addSlot($node,'avatar',["option"]);
    }


    /**
     * 头像组溢出容器 slot rest
     * 参数 (info: { options: Array<{ src: string }>, rest: number })
     * @param Node $node
     * @return $this
     */
    public function slotRest(Node $node): static
    {
        return $this->addSlot($node,'rest',["options","rest"]);
    }
}
